"""
File: yaml_file.py
Author: ershixiong
Date: 2024/3/22
describe:

"""
import pytest

from ddt_framework_02.yaml_item import YamlItem


class YamlFile(pytest.File):
    def collect(self):
        # We need a yaml parser, e.g. PyYAML.
        import yaml

        raw = yaml.safe_load(self.path.open(encoding="utf-8"))
        for name, spec in sorted(raw.items()):
            yield YamlItem.from_parent(self, name=name, spec=spec)
